/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.yy.bugzillahelp;

import com.yy.bugzillahelp.tool.SwingTool;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JTabbedPane;

/**
 *
 * @author Alan
 */
public class TabPopupMenu extends JPopupMenu implements ActionListener {

    private JTabbedPane jTabbedPane;
    private int index;

    public TabPopupMenu(JTabbedPane jTabbedPane) {
        this.jTabbedPane = jTabbedPane;
        this.setRequestFocusEnabled(true);

        JMenuItem jMenuItem = new JMenuItem("Close");
        jMenuItem.addActionListener(this);
        this.add(jMenuItem);
    }

    public void show(int index, int x, int y) {
        this.index = index;
        super.show(jTabbedPane, x, y);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        jTabbedPane.removeTabAt(index);
        this.setVisible(false);
    }
}
